package com.bw1806.shop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.bw1806.pojo.TbSeller;
import com.bw1806.sellergoods.service.TbSellerService;
import entity.PageResult;
import entity.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @描述133333
 * @创建人 wangyue
 * @创建时间2020/11/1115:04
 */
@RestController //controller+responsebody
@RequestMapping("tbSeller")
public class TbSellerController {

    @Reference
    private TbSellerService tbSellerService;

    @RequestMapping("list")
    public List<TbSeller> list(){
        return tbSellerService.findAll();
    }

    /**
     * 分页模糊查询
     * @param tbTbSeller
     * @return
     */
    @RequestMapping("pagelist")
    public PageResult<TbSeller> pagelist(@RequestBody TbSeller tbTbSeller,int pageNum,int pageSize){
        return tbSellerService.pagelist(tbTbSeller,pageNum, pageSize);
    }

    /**
     * 保存方法
     * @param tbTbSeller
     * @return
     */
    @RequestMapping("save")
    public Result save(@RequestBody TbSeller tbTbSeller){
        try {
            tbSellerService.save(tbTbSeller);
            return new Result(true, "增加成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "增加失败");
        }
    }
    /**
     * 根据id获取对象方法-回显
     * @return
     */
    @RequestMapping("getById")
    public TbSeller getById(String id){
        return tbSellerService.getById(id);
    }
    /**
     * 删除方法
     * @return
     */
    @RequestMapping("deletebth")
    public Result deletebth(String[] ids){
        try {
            tbSellerService.deletebth(ids);
            return new Result(true, "删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "删除失败");
        }
    }
}
